---
title: Development Workflow
description: Development workflow for Hopp
---

import { Image } from 'astro:assets';
import connect from "../../../../assets/hopp-connect-app.gif";

## Backend Setup

Before the first run, you need to set up the web app dependencies, database, Redis Docker containers, and create certificates:

```bash
# Install all workspace dependencies from the root
yarn install

# Create SSL certificates for local development
task backend:create-certs

# Start Docker containers for PostgreSQL and Redis
task backend:compose-up

# Start the backend which inits the database
task backend:dev

# If it is the first time you are running the backend, you need to add mock data to the database.
# By default it adds `michael@dundermifflin.com` and `dwight@dundermifflin.com` users.
task backend:add-mock-data
```

After the initial setup, **start the backend with the local LiveKit server**:
You can change the server's configuration in the `backend/env-files/.env.local` file.

```bash
task dev-server
```

## Tauri App Development

Then you can start the Tauri desktop application:

```bash
task app:dev
```

You can get an authentication token with:

```bash
task backend:user-token EMAIL=michael@dundermifflin.com
```

To connect then you need to paste the generated token inside the `Debug` screen inside the app.


<Image src={connect} class="rounded-md w-full mx-auto mt-6" alt="Connect app to account" />


For debugging purposes, you can spawn a clone of the app:

```bash
task app:start-replica-app
```

And generated a token for `Dwight` user with command:

```bash
task backend:user-token EMAIL=dwight@dundermifflin.com
```

Then you can make Dwight call Michael.

## Exposing Services to the Internet

You can expose the backend and LiveKit server to the internet by creating a tunnel. There are multiple tools available for this; one popular option is `cloudflared`.

### Example Cloudflared Configuration

Create a `config.yml` file with the following configuration:

```yaml
tunnel: <tunnel-id>
credentials-file: <path-to-credentials-file>

ingress:
  - hostname: <hostname>
    service: https://localhost:1926

  - hostname: <livekit_hostname>
    service: ws://localhost:7880

  - service: http_status:404
```

This configuration will:

- Expose the backend API (running on port 1926) via HTTPS
- Expose the LiveKit server (running on port 7880) via WebSocket
- Return a 404 for any other requests

Don't forget to update the server's configuration in `env-files/.env.local` when you expose the services to the internet.

Then you have to set the `VITE_API_BASE_URL` environment variable before running the Tauri app.

## Logging

For the tauri app you can enable logging by setting the `RUST_LOG` environment variable.
The values are the same as the ones from [env-logger](https://docs.rs/env_logger/latest/env_logger/#enabling-logging)
, which is what `hopp_core` is using.

For example you could run the app with:

```bash
RUST_LOG=info task app:dev
```

The tauri backend when launches `hopp_core` forwards the log level to it.
